{% extends 'base.html' %}
{% load static %}

{% block title %}Exams{% endblock %}


{% block head %}
    <link rel="stylesheet" href="{% static 'stud_app/css/exam_list.css' %}">
{% endblock %}
    
    
{% block content %}

<div class="container">
<div class="row">
<!-- <div class="col-2"></div> -->
<div class="col-10 offset-1">

<form action="" method="post">
    {% csrf_token %}
    <div class="table-container">
        <table style="margin: auto;"> 
            <thead>
                <tr>
                    <th>Course</th>
                    <th>Exam</th>
                    <th>Start Time</th>
                    <th>End Time</th>
                    <th>Time Limit</th>
                    <th>ATTEND</th>
                </tr>
            </thead>
            <tbody>
                {% for exam in exams %}
                <tr>
                    <td>{{ exam.course_fk.course_name }}</td>
                    <td>{{ exam.exam_name }}</td>
                    <td> 
                        {% if exam.start_time %}
                            {{ exam.start_time }}
                        {% else %}
                            Anytime
                        {% endif %}
                    </td>
                    <td> 
                        {% if exam.end_time %}
                            {{ exam.end_time }}
                        {% else %}
                            Anytime
                        {% endif %}
                    </td>
                    <td>{{ exam.time_limit }}</td>
                    <td>
                        <button type="submit" name="{{ exam.id }}" class="btn btn-lg btn-primary btn-block btn-signin" 
                        {% if now < exam.start_time or now > exam.end_time %}
                            disabled
                        {% endif %}
                        value="{{ exam.id}}">Enter</button>
                    </td>

                </tr>
                {% endfor %}
    
            </tbody>
        </table>
    </div>
</form>           
    
</div>
</div>
</div>


{% endblock %}